package com.onstar.cn.api.v2;

import com.onstar.cn.api.framework.ClazzInjectUtils;
import com.onstar.cn.api.framework.annotation.Path;
import com.onstar.cn.api.framework.annotation.RequestMapping;
import com.onstar.cn.framework.network.entity.RequestEntity;
import com.onstar.cn.framework.utils.GsonHelper;
import com.onstar.cn.mag.joinme.RegisterRequestEntity;

/**
 * @author 6335yz
 * @ClassName: JoinmeService
 * @Description: 注册，升级接口
 * @date 2015年9月6日 下午2:47:43
 */
@Path("/msp/api/v3/user")
public class JoinmeService {

    private String serverURL;

    public JoinmeService(String serverURL) {
        this.serverURL = serverURL;
    }


    /**
     * 注册为车主
     *
     * @param requestEntity
     * @param entity
     * @return
     */
    @RequestMapping("/register/subscriber")
    public RequestEntity registerToSubscriber(RequestEntity requestEntity, RegisterRequestEntity entity) {
        if (requestEntity == null) {
            requestEntity = new RequestEntity();
        }
        String url = ClazzInjectUtils.injectUrl(getClass(), "registerToSubscriber", requestEntity, entity);
        requestEntity.setUrl(serverURL + url);
        if(entity!=null){
            requestEntity.setBody(GsonHelper.toJson(entity));
        }
        return requestEntity;
    }


}
